/**
 * 
 */
package com.ctn.task.entity;

import java.io.Serializable;
import java.util.Date;

import com.ctn.task.condition.TaskCondition;
import com.ctn.task.exec.TaskExecutor;

/**
 * @author Zale
 *
 */
public class Task implements Serializable {
	private static final long serialVersionUID = -3657885971892471289L;
	/**
	 * 任务ID
	 */
	private Long id;
	/**
	 * 任务优先级
	 */
	private TaskPriority priority;
	/**
	 * 任务创建时间
	 */
	private Date createTime;
	
	/**
	 * 执行任务的条件
	 */
	private TaskCondition condition;
	/**
	 * 任务执行器
	 */
	private TaskExecutor executor;
	
	/**
	 * 任务执行结果
	 */
	private TaskResult result;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public TaskCondition getCondition() {
		return condition;
	}

	public void setCondition(TaskCondition condition) {
		this.condition = condition;
	}

	public TaskExecutor getExecutor() {
		return executor;
	}

	public void setExecutor(TaskExecutor executor) {
		this.executor = executor;
	}

	public TaskResult getResult() {
		return result;
	}

	public void setResult(TaskResult result) {
		this.result = result;
	}

	public TaskPriority getPriority() {
		return priority;
	}

	public void setPriority(TaskPriority priority) {
		this.priority = priority;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Task other = (Task) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}



	public static enum TaskPriority{
		very_high,high,normal,low,very_low
	}
	
}
